from fastapi import APIRouter, Depends
from sqlmodel import Session, select
from starlette.requests import Request
from plugin.database import get_db
from pyroaring import BitMap
from models.tags import *

tag_router = APIRouter(prefix="/tag", tags=["用户标签接口"])
def run_user_tag_link(tag_id):
    res = {}
    return res


@tag_router.get("/", summary="获取列表")
def tag_list(request: Request, limit: int = 10, skip: int = 0, db: Session = Depends(get_db)):
    res = {
        "code": 0,
        "message": "success",
        "data": []}
    return res

# @tag_router.get("/{tag_id}", summary="获取详情")
# def tag_detail(request: Request, tag_id: int, db: Session = Depends(get_db)):
#     query_code = select(TagInfo).where(TagInfo.id == 1)
#     results = db.exec(query_code).all()
#     return results
#
#
# @tag_router.post("/", summary="新增")
# def create_tag(item: TagInfo, db: Session = Depends(get_db)):
#     db_tag = TagInfo.model_validate(item)
#     print(db_tag)
#     db.add(db_tag)
#     db.commit()
#     return db_tag
#
#
# @tag_router.put("/{tag_id}", summary="修改")
# def update_tag(tag_id: int, item: TagInfo, db: Session = Depends(get_db)):
#     db_tag = db.get(TagInfo, tag_id)
#     if db_tag is None:
#         return {"message": "Tag not found"}
#     update_data = item.model_dump(exclude_unset=True)
#     return update_data
#
#
# @tag_router.delete("/{tag_id}", summary="删除")
# def delete_tag(tag_id: int, db: Session = Depends(get_db)):
#     db_tag = db.get(TagInfo, tag_id)
#     if db_tag is None:
#         return {"message": "Tag not found"}
#     db.delete(db_tag)
#     db.commit()
#     return {"message": "Tag deleted"}
#
#
# @tag_router.post("/tag_link", summary="新增标签分组")
# def create_user_tag_link_task(tag_id: TagInfo.id, db: Session = Depends(get_db)):
#     # todo: 创建定时任务
#     # data = create_user_tag_link(tag_id)
#     res = {
#         "code": 0,
#         "message": "success",
#         "data": []}
#     return res
